<%--
  Created by IntelliJ IDEA.
  User: Chen
  Date: 2016/4/10
  Time: 15:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>

<c:set var="ctx" value="${pageContext.request.contextPath}" />
<h4>上传论文</h4>

<div>
    <form id="student-paper" method="post" enctype="multipart/form-data">
        <input type="hidden" name="uid" value="<shiro:principal property="id"/>">
        <input type="file" class="upload_file_decription" id="file" name="file">
        <input type="text" class="upload_file_decription" id="description" placeholder="可选的描述" name="description">
        <input type="submit" id="paper-submit"  value="提交"> <span>（最大尺寸：10.0MB）</span>
    </form>
</div>

<h4>上传记录</h4>
<div id="list-data">
</div>

<script id="list-template" type="text/html">
    {{if totalCount == 0}}<p style="font-size: larger;">暂时没有上传记录!</p>{{/if}}
    {{if totalCount != 0}}

    <div class="attachment">
        {{each result as value i}}
        {{if value.attachment != null}}
        <p>
            <img src="${ctx}/assets/img/attachment.png" alt="附件">
            <a href="${ctx}/commons/attachment/download/{{value.attachment.id}}" class="icon icon-attachment">{{value.attachment.fileName}}</a>
            <span class="size">({{value.attachment.fileSize/1000}}KB)- {{value.description}}</span>
            <a class="btn-link paper-del" data='{"id":"{{ value.id }}"}'><img src="${ctx}/assets/img/delete.png" alt=""></a>
            <span class="author">{{value.uploader}}，{{value.attachment.createTime}}</span>
        </p>
        {{/if}}
        {{/each}}
        <div>
            {{#pagination }}
        </div>
    </div>
    {{/if}}
</script>

<script type="text/javascript">
    <c:if test="${env == 'pro' }">
    requirejs(['${ctx}/assets/js/app/student/paper-upload.js']);
    </c:if>
    <c:if test="${env != 'pro' }">
    requirejs(['${ctx}/assets/js/app/student/paper-upload.js']);
    </c:if>
</script>